
var SEARCH_NOTICE_TEXT = "\u8f93\u5165\u5173\u952e\u5b57";
var SEARCH_NOTICE_CSS = "input_notice";
var SEARCH_ACTION = context_path + "/search.do";
function onSearchSubmit() {
	$("#search_submit").click();
	return false;
}
function searchOrder(key) {
	search(key, "order");
}
function search(key, type) {
	if (!key || key == "") {
		key = "";
	}
	if (!type) {
		type = "order";
	}
	var url = SEARCH_ACTION;
	url = jtool.addUrlParam(url, "type", type, true);
	url = jtool.addUrlParam(url, "key", key, true);
	jtool.goto(url);
}
var cateLevel = 1;
function searchinto(id) {
	var level = cateLevel;
	if (!level) {
		level = 1;
	}
	var key = $("#hiddenSearchkey").val();
	//if (key && key != "") {
	level += 1;
	//}
	if (level > 3) {
		level = 3;
	}
	SEARCH_ACTION = jtool.addUrlParam(SEARCH_ACTION, "cateLevel", level, true);
	SEARCH_ACTION = jtool.addUrlParam(SEARCH_ACTION, "cateId", id, true);
	var type = $("#search_box > input:checked[name='type']").val();
	search(key, type);
}
function serachCate(cateId) {
	SEARCH_ACTION = jtool.addUrlParam(SEARCH_ACTION, "cateId", cateId, true);
	search();
}
function searchUpLevel() {
	var level = cateLevel;
	if (level > 1) {
		jtool.addParam("cateLevel", (level - 1));
	}
}
function searchParentCate(id) {
	jtool.addParam("cateId", id);
}
$(document).ready(function () {
	var keyword = $("#search_keyword");
	if (keyword.val() == null || keyword.val() == "") {
		keyword.val(SEARCH_NOTICE_TEXT).addClass(SEARCH_NOTICE_CSS);
	}
	keyword.click(function () {
		if (SEARCH_NOTICE_TEXT == this.value) {
			this.value = "";
			$(this).removeClass(SEARCH_NOTICE_CSS);
		}
	});
	keyword.blur(function () {
		if ("" == this.value) {
			this.value = SEARCH_NOTICE_TEXT;
			$(this).addClass(SEARCH_NOTICE_CSS);
		}
	});
	$("#search_submit").click(function () {
		var key = keyword.val();
		if (key == "" || key == SEARCH_NOTICE_TEXT) {
			alert("\u8bf7\u8f93\u5165\u67e5\u8be2\u5173\u952e\u5b57");
			return;
		}
		var type = $("#search_box > input:checked[name='type']").val();
		search(key, type);
		return false;
	});
});

